﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TVGuide.DataAccess;
using TVGuide.DataAccess.Repository;
using TVGuide.DataAccess.Common;

namespace TVGuide.Parser
{
    public class MainProgram
    {
        static void Main(string[] args)
        {
            Console.WriteLine(DateTime.Today);
            DateTime start = DateTime.Now;
            ProgramRepository pr = ProgramRepository.Instance();
            //var parsers = Parsers.ParsersList;
            //foreach (var parser in parsers)
            //{
            //    var programsList = parser.ParseProgram();
            //    if (programsList.Count != 0)
            //    {

            //        pr.AddRange(programsList);
            //    }
            //    // Save the list to database
            //}

            for (int i = 0; i < 7; i++)
            {
                List<Program> ucomPrList = UCOMParseEngine.ParseAll((DateTime)DateTime.Today.AddDays(i));
                //List<Program> ntvPrList = NTVPlusParseEngine.ParseAll(DateTime.Today.AddDays(i)).Distinct().ToList();
 
                if (ucomPrList.Count != 0 )
                {
                   TVGuide.DataAccess.Utilsities.addPrograms(ucomPrList);
                }

                //if (ntvPrList.Count != 0)
                //{
                //    TVGuide.DataAccess.Utilsities.addPrograms(ntvPrList);
                //}
            }

            Console.Write("Time elapsed " + (DateTime.Now.Minute - start.Minute) + " minutes.");
            Console.Read();
           
        }
    }
}
